InstancesΒΆ
The procedural instancing workflow
The Guerilla procedural instancing workflow is a solution to render a high (millions+) number of instances. The procedural instancing generates instances at render time, keeping the complexity at the end of the rendering process. The simulation and the export processes stay light.
Generate the instances
The Instance node is a procedural geometry node that generates instances. The instances inherit the instance meshes attributes and shaders. The Instance node has to be linked to a scalp mesh, some instance meshes and some guide curves to drive the instances orientation if required.
- Press Ctrl+Space to open the Node Picker.
- Type Instances and select the Instances item.
The Instances procedural can be created directly in the scene or using the RenderGraph. Using the RenderGraph makes it usually simpler to pipeline in production as the procedural is packaged with the RenderGraph.
The scalp mesh
The scalp is the mesh on which the instances are generated.
This method only applies to procedurals created in the RenderGraph.
- Drag'n drop the scalp object into the RenderGraph to create a Path node.
- Connect its output to the scalp input of the Instances procedural.
Use this method to get an OpenGL feedback of the procedural.
- Select the Instances procedural node.
- Open the 'Procedural' tab.
- Press the 'Scalp -> Edit' button.
- In the linker window, select in the right column the scalp mesh.
Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.
- Put the scalp objects in a specific set, like "Scalp" using the RenderGraph.
- Select the Instances procedural node.
- Add to the attribute
Instances -> Procedural -> Scalp Set the new set.
The instance meshes
The instance meshes are the meshes the procedural will instanciate.
This method only applies to procedurals created in the RenderGraph.
- Drag'n drop the instance objects into the RenderGraph to create a Path node.
- Connect its output to the instances input of the Instances procedural.
Use this method to get an OpenGL feedback of the procedural.
- Select the Instances procedural node.
- Open the 'Procedural' tab.
- Press the 'Instances -> Edit' button.
- In the linker window, select in the right column all the instance meshes or the group nodes.
Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.
- Put the instance meshes ot the group nodes in a specific set, like "Instances" using the RenderGraph.
- Select the Instances procedural node.
- Add to the attribute
Instances -> Procedural -> Instances Set the new set.
By default, if multiple instance meshes are connected to the Instance node, the procedural will instanciate all the meshes (or all the child meshes of the group) at every instance.
You may want to randomly select different set of meshes at every instances. To do that, you have to mark every instance meshes
of the same object with an
- Select all the meshes of a same instance object.
- In the
SceneGraphNode -> Dynamic Attributes section, type 'ObjectName', selectstring and press theAdd button.
- Set the new
ObjectName attribute with the object name. - Do that for every instance objects.
By default, each instance type is selected at random, with identical probability for each type. Add a Density### attribute on the scalp, where ### matches the instance ObjectName attribute, to control the density of the instance. For instance, if the ObjectName value of the instance is 'TreeA', then the scalp attribute must be named 'DensityTreeA'.
Control an instancing attribute with a sub shader
Most instancing attributes, like the density or the orientation, can be controlled by a scalp objects sub shader, like a simple texture, or any other sub shader expression.
In the
- In the RenderGraph, add on the scalp objects a
RenderGraph/MaterialOverride node. - In the MaterialOverride node, add a float attribute named like the name defined in the Instances procedural, Density here.
- Drag and drop your mask texture on the edit box.
Orient the instances
The instances can be oriented or not. To orient the instances, you have to paint direction maps in a painting tool (like Mari®) or export some guides from any third party grooming solution (like Maya® Hair or Shave and Haircut®). Then export everything in Guerilla Render.
Using a texture sub shader
The simplest solution to orient the instances is to use a texture sub shader. There is two types of textures. The polar maps, generated by Maya Fur, and the direction maps, generated by Mari®.
- Set the
Instances -> Procedural -> Orientation -> Polar -> Polar Shader Mode attribute to Polar or Direction. - As explained before, add to the scalp objects color sub shader named Polar and drop your texture into it.
Using guide curves
Another solution to orient the instances is to use guide curves. The guide curves can be simulated in a third party tool. The procedural instances interpolates the guides to get the instances orientation and inclinaison.
The guides can be any kind of curves. For example :
- A Maya® Hair node with guides inside
- A group node with Maya® curves inside
- A Shave And Haircut® node
- Alembic curves
Use this method to get an OpenGL feedback of the procedural.
- Select the Instances procedural node.
- Open the 'Procedural' tab.
- Press the 'Guides -> Edit' button.
- In the linker window, select in the right column the guide curves object.
Use this method to connect the procedural using the RenderGraph. This connection method won't work with OpenGL.
- Put the guide curves object objects in a specific set, like "Guides" using the RenderGraph.
- Select the Instances procedural node.
- Add to the attribute
Instances -> Procedural -> Guides Set the new set.
Instancing on a point cloud
Alternatively, you can connect the procedural Scalp to a point cloud instead of a plain mesh, the instances will be located at each point.
Orientation using quaternion
You can control the orientation of the instance with the orient channel on the point could. The Instances procedural expects this value to be a unit quaternion.
Selecting the instances
You can control the objects to instance at each point by assigning an ObjectId integer to each point of the cloud. The procedural will match this value with the ObjectId attribute of the instance meshes to instanciate.
Bake the implantation
If you are doing an animation, you probably want the instances implantation to be consistent over time to avoid flicking. To do that, you have to bake the fiber implantation.
- Select the Instances procedural node.
- Turn the 'Implantation -> Implantation Mode' to 'Bake'
- Wait for an OpenGL update or render the procedural
- Turn the 'Implantation -> Implantation Mode' to 'Read'
Now the implantation is always the same. The Implantation parameters are no longer used.
Shading
The ST attribute
- Enable the
Instances -> Procedural -> Attributes-> Generate ST attribute. The st coordinates are stored in thesurf_st shader attribute.
- Add this sub shader to the instance
Surface -> Diffuse Color attribute
The ID attribute
- Enable the
Instances -> Procedural -> Attributes -> Generate ID attribute. The ID coordinates are stored in theid shader attribute.
- Add this sub shader to the instance
Surface -> Diffuse Color attribute
Other attributes
The procedural can also transfer the clump ID in the